<%--
  Created by IntelliJ IDEA.
  User: hongfive
  Date: 2019/1/7
  Time: 20:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basepath = request.getScheme()
            + "://" + request.getServerName()
            + ":" + request.getServerPort() + "/" + path;
%>
<html>
<head>
    <meta charset="UTF-8">
    <title>新增分类</title>
    <link rel="stylesheet" href="<%=basepath%>/statics/backcss/css/add.css">
    <link rel="stylesheet" href="<%=basepath%>/statics/backcss/css/bootstrap.min.css">
    <script src="<%=basepath%>/statics/backcss/js/jquery.min.js"></script>
    <script>
        function add() {
            var cgName=$("input[name='cgName']").val();
            if (cgName=="请输入新分类"||cgName==" "){
                alert("请输入新分类")
            }
            $.ajax({
                url:'../category/insertCg',
                dataType:'json',
                data:{
                    cgName: cgName
                },
                async:false,
                type:'post',
                success: function (data) {
                    var json=data;
                    if (json.code==1){
                        alter(json.message);
                        location.href="../category/index"
                    }
                    else {
                        alert("insert no");
                    }
                },
                error: function (er) {
                    alert(er)
                }
            })
        }
    </script>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">
                油画管理
            </a>
        </div>
    </div>
</nav>
<div class="container">
    <div class="jumbotron">
        <h1>Hello, admin!</h1>
        <p>请小心的更新油画分类。。。</p>
    </div>
    <div class="page-header">
        <h3><small>编辑</small></h3>
    </div>
    <form class="form-horizontal" action="../category/index" method="post">
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">名称 ：</label>
            <div class="col-sm-8">
                <input type="hidden" name="id" class="form-control" id="id" value="分类一">
                <input name="cgName" class="form-control" id="name" value="请输入新分类">
            </div>
        </div>
        <%--<div class="form-group">
            <label for="name" class="col-sm-2 control-label">描述 ：</label>
            <div class="col-sm-8">
                <input type="text" name="description" class="form-control" id="description" value="描述一">
            </div>
        </div>--%>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary" onclick="add()">添加</button>&nbsp;&nbsp;&nbsp;
            </div>
        </div>
    </form>
</div>
<footer class="text-center" >
</footer>
</body>
</html>

